import { debounce } from "lodash-es";
const useSchIpt = defineStore("schIpt", () => {
  const iptEl = useTemplateRef<HTMLInputElement>("iptRef");
  const schIpt = ref("");
  const router = useRouter();
  const setSchIpt = debounce(() => {
    const el = unref(iptEl);
    if (el) {
      console.log(el.value);
      schIpt.value = el.value;
    } else {
      console.warn("Input element is not available.");
    }
  }, 300);
  function handleJump(it: any) {
    router.push(`/schRes?cate=${it}`);
  }
  return { schIpt, setSchIpt, handleJump };
});
export const useSchIptRefs = () => {
  return storeToRefs(useSchIpt());
};
export default useSchIpt;
